The following document assumes the reader has a knowledge of writing module extensions for Perl, and is going to attempt to write one for Perl for Win32. Due to some implementation issues that have yet to be resolved in Perl5 build 100 beta 1, writing extensions is still a little tricky. This document will be updated for the next build, which will have these issues addressed.
Here is a quick overview of the steps used to write module extensions.
In order to make extensions build with the current build ( 100 beta 1 ) of Perl for Win32, a few changes must be made to the C++ file generated by xsubpp. This is unfortunate, and will not be a permanent feature of Perl for Win32. Due to the way the perl100.dll was implemented, functions in the C++ file for the extensions that are not defined as XS( funcname ) will cause compilation errors when they attempt to use any perl internal functions ( eg: SvIV, etc ).The way to fix this problem is to add CPerl* pPerl as an argument to this function.
Eg:
// note the use of the pPerl here.
int constant( CPerl* pPerl, int this )
{
if( this == 0 ){
printf("zero entered\n");
return( 0 );
}
else{
printf(" a non-zero integer was entered\n");
return(1);
}
}
XS(MyPerlFunc)
{
dXSARGS;
int RETVAL;
int arg;
if( items < 1 ){
croak("usage: MyPerlFunc( $value )\n");
}
arg = (int) SvIV( ST(0));
// note the use of the pPerl here.
RETVAL = constant( pPerl, arg );
XSRETURN(RETVAL);
}